home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 483 / mkrscsrc / retrv.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-04-26  |  3.2 KB  |  120 lines

  1. #include "stdio.h"
  2. #include "gemdefs.h"
  3. #include "obdefs.h"
  4. #include "osbind.h"
  5. #include "mkrsc.h"
  6. #include "globals.h"
  7. #include "strings.h"
  8. #include <fcntl.h>
  9.  
  10. int ret_rsc()
  11. {
  12.     windowptr    thewin;
  13.     RSHDR rsc_struct;
  14.     int fildes, skres, i, j, button;
  15.     OBJECT *treeptr, *iconptr;
  16.     int order[MAXONUM], num_objs;    
  17.     long red;
  18.     objtreeptr sbstrct;
  19.     TEDINFO    *tiptr;
  20.     ICONBLK    *icptr;
  21.     char temp[20], pname[30];
  22.     int len;
  23.  
  24.     if(!(thewin = new_window()))
  25.         return;
  26.     if(!(getfile(thewin)))
  27.     {    dispose_win_resources(thewin);
  28.         return;
  29.       }
  30.       open_window(thewin);
  31.       graf_mouse(2,0L);
  32. #ifndef __GNUC__
  33.       fildes = open(thefrontwin->title,O_BINARY);
  34.       if( (fildes == -1)||(red = Fread(fildes,36L,(char *)&rsc_struct)) != 36)
  35. #else
  36.     fildes = open(thefrontwin->title,0);
  37.     if( (fildes < 0)||(red = Fread(fildes,36L,(char *)&rsc_struct)) != 36)
  38. #endif
  39.               {    button = form_alert(1, "[1][ File read error ][OK]");
  40.                   close(fildes);
  41.                   return;
  42.             }
  43.     close(fildes);
  44.  
  45.     if (!rsrc_load(thefrontwin->title))
  46.     {    form_alert(1, "[0][Cannot find .RSC file|Aborting ...][OK]");
  47.         return;
  48.     }
  49.  
  50.     graf_mouse(0,0L);
  51.  
  52.     iconptr = &onleft[TUNKNOWN];
  53.  
  54.     for(i=0;i<rsc_struct.rsh_ntree;i++)
  55.     {    rsrc_gaddr(0, i, &treeptr);
  56.         num_objs = trav_tree(treeptr,order);
  57.         add_lefticon(iconptr,TUNKNOWN,1);
  58.         sbstrct = thewin->inwindow->treelink[i+1];
  59.         sbstrct->count = num_objs - 1;
  60.     for(j=0;j <(num_objs);j++)
  61.         {    sbstrct->objt[j] = treeptr[order[j]];
  62.     switch (treeptr[j].ob_type)
  63.     {
  64.         case G_TEXT        :
  65.         case G_BOXTEXT    :
  66.         case G_FTEXT    :
  67.         case G_FBOXTEXT    : 
  68.             sbstrct->ti[j] = *((TEDINFO *)(treeptr[order[j]].ob_spec));
  69.             sbstrct->objt[j].ob_spec = (char *)&sbstrct->ti[j];
  70.             strcpy(sbstrct->strings[j],
  71.                 ((TEDINFO *)(treeptr[order[j]].ob_spec))->te_ptext);
  72.             sbstrct->ti[j].te_ptext = sbstrct->strings[j];
  73.             strcpy(sbstrct->template[j],
  74.                 ((TEDINFO *)(treeptr[order[j]].ob_spec))->te_ptmplt);
  75.             sbstrct->ti[j].te_ptmplt = sbstrct->template[j];
  76.             strcpy(sbstrct->valid[j],
  77.                 ((TEDINFO *)(treeptr[order[j]].ob_spec))->te_pvalid);
  78.             sbstrct->ti[j].te_pvalid = sbstrct->valid[j];
  79.             break;
  80.         case G_BUTTON    :
  81.         case G_STRING    :
  82.         case G_TITLE    :
  83.             strcpy(sbstrct->strings[j], treeptr[order[j]].ob_spec);
  84.             sbstrct->objt[j].ob_spec = sbstrct->strings[j];
  85.             break;
  86.         case G_ICON        :
  87.             sbstrct->icblk[j] = *((ICONBLK *)(treeptr[order[j]].ob_spec));
  88.             sbstrct->objt[j].ob_spec = (char *)&sbstrct->icblk[j];
  89.             strcpy(sbstrct->strings[j],
  90.                 ((ICONBLK *)(treeptr[order[j]].ob_spec))->ib_ptext);
  91.             sbstrct->icblk[j].ib_ptext = sbstrct->strings[j];
  92.             break;
  93.     }
  94.         }    /*    end of for(j=....    */
  95. /*    reset the pointers in the object tree...  newpos() in tree.c    */
  96.             for (j=0;j<num_objs;j++)
  97.             {    sbstrct->objt[j].ob_next =
  98.                      newpos(sbstrct->objt[j].ob_next,num_objs,order);
  99.                 sbstrct->objt[j].ob_head =
  100.                      newpos(sbstrct->objt[j].ob_head,num_objs,order);
  101.                 sbstrct->objt[j].ob_tail =
  102.                      newpos(sbstrct->objt[j].ob_tail,num_objs,order);
  103.  
  104.             }
  105.     }    /* end of for i=....    */
  106.     len = strlen(thefrontwin->title);
  107.     for(i = len - 1; i > 0; i--)
  108.         if(thefrontwin->title[i] == '.')
  109.             break;
  110.     strncpy(temp,thefrontwin->title,i);
  111.     temp[i] = '\0';
  112.     sprintf(pname,"%s.DEF",temp);    
  113.     read_def(pname);
  114.  
  115. }
  116.         
  117.     
  118.  
  119.         
  120.